package com.rule.easyrule.service;

import com.rule.easyrule.entity.BizOrder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
@Slf4j
@Service
public class OrderService {
    /**
     * 折扣处理方法
     * @param param 参数
     */
    public static void doDiscountAction(Object param) {
        //可通过 instanceof 操作符来判断对象的具体类型
        if (param instanceof BizOrder) {
            BizOrder order = ((BizOrder) param);
            //Java.math.BigDecimal.multiply()方法,通过此BigDecimal相乘的值
            log.error("商品goods:{},折后amount:{}", order.getGoods(), order.getAmount().multiply(order.getDiscount()));
        }
    }
}
